<style lang="less">
</style>

<template>
    <div style="padding-left:80px">
        <el-form
            :model="queryForm"
            label-width="130px"
            style="height:150px"
            :rules="rules"
            ref="addformThree"
            label-suffix="："
        >
            <el-row :getter="24">
                <el-col :span="18">
                    <el-form-item :label="$t('题库名称')" prop="questionPoolName">
                        <el-input
                            v-model="queryForm.questionPoolName"
                            maxlength="32"
                            :placeholder="$t('请输入')"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <el-dialog
            width="25%"
            ref="innerDialog"
            :title="$t('graduateBase.prompt')"
            :visible.sync="innerVisible"
            append-to-body
            :top="'28vh'"
        >
            <div style="text-align: left;margin-bottom: 25px;">
                {{ $t('graduateBase.cancelTip') }}
            </div>
            <div style="text-align: right;">
                <el-button type="primary" @click="confirmInner">
                    {{ $t('common.btn.confirm') }}
                </el-button>
                <el-button @click="cancelInner">{{ $t('common.btn.cancel') }}</el-button>
                <el-button type="primary" @click="confirmAndClose">
                    {{ $t('graduateBase.saveAndClose') }}
                </el-button>
            </div>
        </el-dialog>
        <el-row type="flex" class="row-bg" justify="end">
            <el-button @click="cancelDialog">{{ $t('overseasInstitutions.cancel') }}</el-button>
            <el-button type="primary" @click="conserve">
                {{ $t('overseasInstitutions.save') }}
            </el-button>
        </el-row>
    </div>
</template>

<script>
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import graduateStudent from 'common/src/api/graduateStudent/graduateStudent'
import interAcaConference from 'common/src/api/internationalCommunication/interAcaConference'
import { getALLCollege } from 'common/src/api/internationalExchanges/exchangeCollegeManagement'
import forumProject from 'common/src/api/academicForums/forumProject'

export default {
    props: {
        dataList: {
            type: String
        },
        dataProp: {
            type: String
        },
        dataListPropName: {
            type: Object
        },
        dataQueryForm: {
            type: Object
        },
        dataQueryName: {
            type: Object
        },
        showFlag: {
            type: Boolean
        },
        agent: {
            type: Boolean,
            default: false,
            required: false
        },
        admin: {
            type: Boolean,
            default: false,
            required: false
        }
    },
    data() {
        return {
            multipleSelection: [],
            dataList: [],
            fileList: [],
            queryForm: {
                questionPoolName: '',
                categoryId: ''
            },
            innerVisible: false,
            id: '',
            restaurants: [],
            formsLearn: [],
            options: {
                facultys: [],
                timeList: [],
                title: [],
                nationId: [],
                regionList: []
            },

            rules: {
                questionPoolName: [
                    { required: true, message: this.$t('请输入题库名称'), trigger: 'blur' }
                ]
            }
        }
    },
    watch: {
        dataListPropName: {
            handler: function(newV, oldV) {
                if (this.dataProp == '编辑') {
                    this.queryForm = this.dataListPropName
                } else {
                    this.queryForm.questionPoolName = ''
                }
            },
            deep: true,
            immediate: true
        }
    },
    created() {
        this.dataQueryName

    },
    mounted() {},
    methods: {
        // 内层弹出确定
        confirmInner() {
            this.dataListPropName = {}
            this.$refs['addformThree'].resetFields()
            this.innerVisible = false
            this.$emit('cancel-dialog', false)
        },
        // 内层弹出取消
        cancelInner() {
            this.innerVisible = false
        },
        // 内层弹出保存关闭
        confirmAndClose() {
            this.innerVisible = false
            this.conserve()
        },
        // 取消
        cancelDialog() {
            this.$refs['addformThree'].resetFields()
            this.$emit('cancel-dialog', false)
        },

        // 保存
        conserve() {
            this.$refs['addformThree'].validate(valid => {
                if (valid) {
                    if (this.dataProp === '新增') {
                        this.$emit('affirm-name', this.queryForm, this.dataQueryForm)
                    } else {
                        this.queryForm.id = this.dataListPropName.id
                        this.$emit('affirm-name', this.queryForm, this.dataQueryForm)
                    }
                }
            })
        }
    }
}
</script>
